//
//  ItemButtonView.m
//  SSC
//
//  Created by 红沙尘 on 2017/9/4.
//  Copyright © 2017年 红沙尘. All rights reserved.
//

#import "ItemButtonView.h"

@implementation ItemButtonView
{
    __weak IBOutlet UILabel *titleLabel;
    __weak IBOutlet UILabel *subTitleLabel;
    
    __weak IBOutlet UIImageView *imgView;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.layer.cornerRadius  = 5;
    self.layer.masksToBounds = YES;
    self.layer.borderColor = [UIColor colorWithHexString:@"#eeeeee"].CGColor;
    self.layer.borderWidth = LineHeight;
}

- (void)loadWithDict:(NSDictionary *)dict {
    
    NSString *title = dict[kItemTitleKey];
    NSString *subTitle = dict[kItemSubtitleKey];
    
    titleLabel.text = title;
    subTitleLabel.text = subTitle;
    
    if ([title isEqualToString:@"重庆"] && [subTitle isEqualToString:@"时时彩"]) {
        imgView.image = LoadImage(@"CaizhongA");
    } else if ([title isEqualToString:@""] && [subTitle isEqualToString:@"两分彩"]) {
        imgView.image = LoadImage(@"CaizhongB");
    } else {
        imgView.image = LoadImage(@"CaizhongMore");
    }
}

- (IBAction)itemPressed:(UIButton *)button {
    
    if ([self.delegate respondsToSelector:@selector(itemButtonView:atIndex:)]) {
        [self.delegate itemButtonView:self atIndex:self.tag];
    }
}

- (NSString *)title {
    return titleLabel.text;
}

- (NSString *)subTtile {
    return subTitleLabel.text;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
